package com.project.easy.common.framework.web.service.impl;

import com.project.easy.common.log.core.dto.WriteLogDto;
import com.project.easy.common.log.core.service.ILogQueryExtend;
import  com.project.easy.common.util.util.IPUtil;
import com.project.easy.common.framework.web.servlet.HttpServletUtils;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @author GreatorMan.cool
 * @copyright: Copyright (c) 2020
 * @company: 扬起科技有限公司
 * @date 2021/10/27 23:09
 * @description:日志查询扩展
 */
@Component
public class DefaultLogQueryExtend implements ILogQueryExtend {
    /**
     * 获取当前用户名称
     * @param writeLogDto 日志对象
     * @return true 处理成功 false 处理失败
     */
    @Override
    public Boolean query(WriteLogDto writeLogDto) {
        if (!Objects.isNull(writeLogDto)) {
            writeLogDto.setIp(IPUtil.getIpAddr(HttpServletUtils.getHttpServletRequest()));
            writeLogDto.setRequestUrl(HttpServletUtils.getRequestUrl(HttpServletUtils.getHttpServletRequest()));
        }
        return Boolean.TRUE;
    }
}
